#include "bignum.h"
#include <iostream>

using namespace std;

static BigNum C[64], A[64];
/*****************************
*定义:
*A[n]: n个顶点的所有图
*B[n]: n个顶点的非连通图
*C[n]: n个顶点的连通图
*递推:
*A[n] = {
*    2**Combination(n,2), n>1 
*    1, n=1
*B[n] = {
*    C[1]*A[n-1]*Combination(n-1, 0)+C[2]*A[n-2]*Combination(n-1, 1)...+C[n-1]*A[1]*Combination(n-1, n-2)
*       = sigma(i=1 -> n-1) C[i]*A[n-i]*Combination(n-1, i-1), n>1
*    0, n=1
*}
*C[n] = A[n]-B[n]    
******************************/

static BigNum bi_pow2(int m) {
    short base = 1<<13;
    BigNum res(1);
    for(int i=m/13; i>0; i--) {
        res *= base;
    }
    res *= 1<<(m%13);
    return res;
}
static void max_graph(int n) {
    if(A[n] != 0) return;
    //A[n] = bi_pow2(n*(n-1)/2);
    A[n] = BigNum(2)^(n*(n-1)/2);
}
static void max_connected_graph(int n) {
    //if(C[n] != 0) return;
    BigNum Cmb = 1; //Combination(n-1, i-1)
    BigNum Bn; // B[n]
    for(int i=1; i<n; i++) {
       //max_connected_graph(i);
        //max_graph(n-i); //A[n-i]
        Bn += C[i]*A[n-i]*Cmb;
        Cmb *= n-i;
        Cmb /= i;
    }
    max_graph(n); //A[n]
    C[n] = A[n] - Bn;
       
}
static void max_connected_graph_init(void) {
    A[1] = 1; A[2] = 2; A[3] = 8; A[4] = 64;
    C[1] = 1;
    C[2] = 1;
    C[3] = 4;
    C[4] = 38;
}

int main(void) {
    max_connected_graph_init();
    for(int i=5; i<51; i++) {
        max_connected_graph(i);
    }
    int n;
    while(true) {
        cin >> n;
        if(n == 0) break;
        cout << C[n] << endl;
    }
    return 0;
}
